import { constants } from '../store';
import { fromJS } from 'immutable';

const defaultState = fromJS({
  focus: false,
  list: ['s','sda'],
  totalPage: 1,
  page: 0,
  mouseIn: false,
})
const headerReducer = (state=defaultState, action) => {
  switch (action.type) {
    case constants.CHANGE_FOCUS:
      return state.set('focus', true);
    case constants.CHANGE_BLUR:
      return state.set('focus', false);
    case constants.MOUSE_ENTER:
      return state.set('mouseIn', true);
    case constants.MOUSE_LEAVE:
      return state.set('mouseIn', false);
    case constants.CLICK_PAGE:
      return state.set('page', action.page);
    case constants.GET_LIST:
      return state.merge({
        list: action.list,
        totalPage:action.totalPage
      });
    default :
      return state
  }
}

export default headerReducer
